import uvicorn
from fastapi import FastAPI

from app.admin.routers import login
from app.dependencies.database import Base, engine
from app.exceptions.global_exc import configure_exception
from config import get_settings

settings = get_settings()
app = FastAPI(
    debug=settings.debug,
    title=settings.title,
    description=settings.description,
    version=settings.version,
)

# 注册后台路由
app.include_router(login.router, prefix='/admin')

# 导入全局异常处理函数
configure_exception(app)

# 创建数据库
Base.metadata.create_all(bind=engine)

if __name__ == "__main__":
    uvicorn.run("main:app")
